package com.rabbitmq.demo.controller;

import com.rabbitmq.demo.conf.SimpleQueueConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 简单模式生产者
 * @Author yi.cheng
 * @Date 2023-7-12 10:53
 **/
@RestController
public class SimpleQueueProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/api/simple")
    public String sendSimpleQueueMsg(){
        String msg = "this is simple queue message";
        rabbitTemplate.convertAndSend("", SimpleQueueConfig.SIMPLE_QUEUE_NAME,msg.getBytes());
        return "ok";
    }
}
